var a = require("../../../@babel/runtime/helpers/toConsumableArray"), t = require("../../../mycomponent/yz_pay/yz_pay"), e = getApp();

Page({
    behaviors: [ t ],
    data: {
        goodList: [],
        totalNum: 0,
        totalPrice: "",
        order_pay_id: "",
        payerImg: "",
        payerName: "",
        pid: "",
        mid: "",
        payKeyboardShow: !1
    },
    onLoad: function(a) {
        console.log("options:", a), this.setData({
            order_id: a.order_id,
            mid: a.mid,
            pid: a.pid
        }), this.getPayerInfo(), this.getOrderDetail();
    },
    onReady: function() {},
    onShow: function() {},
    getPayerInfo: function() {
        var a = this, t = e.getNetAddresss("order.merge-pay.anotherPayOrder");
        t += "&order_ids=" + this.data.order_id + "&mid=" + this.data.mid, t += "&pid=" + this.data.pid, 
        t += "&plugin=parent_payment", e._getNetWork({
            url: t,
            success: function(t) {
                if (1 == t.data.result) {
                    var e = t.data.data;
                    a.setData({
                        payerImg: e.member.avatar,
                        payerName: e.member.nickname,
                        order_pay_id: e.order_pay.id,
                        totalPrice: e.order_pay.amount
                    });
                    var r = [], o = e.buttons;
                    for (var i in o) 1 != o[i].value && 3 != o[i].value || r.push(o[i]);
                    a.setData({
                        buttons: r
                    }), wx.setNavigationBarTitle({
                        title: t.data.data.plugin_name || "上级代付"
                    });
                } else wx.showToast({
                    title: t.data.msg,
                    icon: "none",
                    duration: 2e3,
                    success: function() {
                        wx.reLaunch({
                            url: "/packageG/index/index"
                        });
                    },
                    fail: function() {}
                }), console.log("错误", t.data.msg);
            },
            fail: function(a) {}
        });
    },
    getOrderDetail: function() {
        var a = this, t = e.getNetAddresss("order.another-pay-detail");
        t += "&order_id=" + this.data.order_id + "&mid=" + this.data.mid, t += "&pid=" + this.data.pid, 
        e._getNetWork({
            url: t,
            success: function(t) {
                console.log("ressss::::", t), 1 == t.data.result ? a.formatGoods(t.data.data) : (e.tips(t.data.msg), 
                console.log("错误", t.data.msg));
            },
            fail: function(a) {}
        });
    },
    formatGoods: function(t) {
        var e = 0, r = [];
        t.forEach(function(t) {
            return r.push.apply(r, a(t.has_many_order_goods)), e += t.goods_total;
        }), this.setData({
            totalNum: e,
            goodList: r
        });
    },
    onShareAppMessage: function() {},
    confirm: function(a) {
        var t = a.currentTarget.dataset.value, e = a.currentTarget.dataset.btn;
        this.handlePay(e, t);
    }
});